extern crate fejpsl_contract;
extern crate fejpsl_dao;

use fejpsl_contract::banner::Banner;
use fejpsl_contract::article::Article;
use fejpsl_contract::friend::{ FriendMessage, Messager};
use fejpsl_contract::follow::{ FollowPageData};
use fejpsl_contract::user::{User, UserKeyData};
use fejpsl_contract::wall::{ WallReader, WallComment, WallPageData};
use fejpsl_contract::rank::{Fan, FanPageData, LevelScorePageData};
use fejpsl_contract::exam::exam_paper::{PaperPageData};
use fejpsl_contract::exam::single_answer::{SingleAnswer};
use fejpsl_contract::exam::multiple_answer::MultipleAnswer;
use fejpsl_contract::exam::true_false_question::TrueFalseQuestion;
use fejpsl_contract::exam::blank_filling_question::BlankFillingQuestion;
use fejpsl_contract::china::China;
use fejpsl_contract::community::room::{RoomPageData, RoomKeyData, RoomData};
use fejpsl_contract::community::member::{ MemberData};
use fejpsl_contract::community::table::TablePageData;
//use std::time::SystemTime;

pub async fn get_banner_by_id(id:&String) -> Option<Banner> {
    if id.is_empty() {
        return None
    }
    return fejpsl_dao::banner::get_banner_by_id(id).await;
}

pub async fn delete_banner_by_id(id:&String) -> Option<bool> {
    if id.is_empty() {
        return None
    }
    return fejpsl_dao::banner::delete_banner_by_id(id).await;
}

pub async fn list_banner() -> Option<Vec<Banner>> {
    return fejpsl_dao::banner::list_banner().await;
}

pub async fn insert_banner(item_desc:&String,image_path:&String,is_visible:&i32,item_order:&i32,title:&String,item_type:&i32,url:&String) -> Option<Banner> {
    if url.is_empty() || item_desc.is_empty() {
        return None
    }
    return fejpsl_dao::banner::insert_banner(&item_desc,&image_path,&is_visible,&item_order,&title,&item_type,&url).await;
}

pub async fn top_list_article() -> Option<Vec<Article>> {
    return fejpsl_dao::article::top_list_article().await;
}
pub async fn get_article_list_by_page_no(page_no:&String) -> Option<Vec<Article>> {
    if page_no.is_empty() {
        return None
    }
    return fejpsl_dao::article::get_article_list_by_page_no(page_no).await;
}
//mod friend
pub async fn messager_list(page_no:&i32,user_uuid:&String) -> Option<Vec<Messager>> {
    return fejpsl_dao::friend::messager_list(page_no,user_uuid).await;
}
pub async fn friend_message_list(page_no:&i32,send_user_uuid:&String,receive_user_uuid:&String) -> Option<Vec<FriendMessage>> {
    return fejpsl_dao::friend::friend_message_list(page_no,send_user_uuid,receive_user_uuid).await;
}
pub async fn list_my_follow(page_no:&i32,user_uuid:&String) -> FollowPageData {
    return fejpsl_dao::follow::list_my_follow(page_no,user_uuid).await;
}
pub async fn list_follow_me(page_no:&i32,user_uuid:&String) -> FollowPageData {
    return fejpsl_dao::follow::list_follow_me(page_no,user_uuid).await;
}
pub async fn list_block_people(page_no:&i32,user_uuid:&String) -> FollowPageData {
    return fejpsl_dao::follow::list_block_people(page_no,user_uuid).await;
}
//mod user
pub async fn get_user_by_id(id:&String) -> Option<User> {
    if id.is_empty() {
        return None
    }
    return fejpsl_dao::user::get_user_by_id(id).await;
}
pub async fn get_user_by_uuid(user_uuid:&String) -> Option<User> {
    if user_uuid.is_empty() {
        return None
    }
    return fejpsl_dao::user::get_user_by_uuid(user_uuid).await;
}
pub async fn user_register(user_name:&String,password:&String) -> Option<User> {
    if user_name.is_empty() || password.is_empty() {
        return None
    }
    return fejpsl_dao::user::user_register(&user_name,&password).await;
}
pub async fn user_login(user_name:&String,password:&String) -> Option<User> {
    if user_name.is_empty() || password.is_empty() {
        return None
    }
    return fejpsl_dao::user::user_login(&user_name,&password).await;
}
pub async fn update_user_by_id(id:&i32,user_name:&String,real_name:&String,age:&i32,sex:&i32,birth_day:&String,phone:&String) -> Option<bool> {
    if user_name.is_empty() {
        return None
    }
    return fejpsl_dao::user::update_user_by_id(id,user_name,real_name,age,sex,birth_day,phone).await;
}
pub async fn update_user_avatar(user_uuid:&String,avatar_text:&String) -> Option<UserKeyData> {
    if avatar_text.is_empty(){
        return None
    }
    return fejpsl_dao::user::update_user_avatar(user_uuid,avatar_text).await;
}
pub async fn update_user_phone(user_uuid:&String,phone:&String) -> Option<UserKeyData> {
    if phone.is_empty(){
        return None
    }
    return fejpsl_dao::user::update_user_phone(user_uuid,phone).await;
}
pub async fn update_user_email(user_uuid:&String,email:&String) -> Option<UserKeyData> {
    if email.is_empty(){
        return None
    }
    return fejpsl_dao::user::update_user_email(user_uuid,email).await;
}
pub async fn update_user_birthday(user_uuid:&String,key:&String) -> Option<UserKeyData> {
    if key.is_empty(){
        return None
    }
    return fejpsl_dao::user::update_user_birthday(user_uuid,key).await;
}
pub async fn update_user_sex(user_uuid:&String,key:&i32) -> Option<UserKeyData> {
    if user_uuid.is_empty(){
        return None
    }
    return fejpsl_dao::user::update_user_sex(user_uuid,key).await;
}
pub async fn update_user_is_explicit(user_uuid:&String,key:&i32) -> Option<UserKeyData> {
    if user_uuid.is_empty(){
        return None
    }
    return fejpsl_dao::user::update_user_is_explicit(user_uuid,key).await;
}
pub async fn update_user_nice_name(user_uuid:&String,key:&String) -> Option<UserKeyData> {
    if key.is_empty(){
        return None
    }
    return fejpsl_dao::user::update_user_nice_name(user_uuid,key).await;
}
pub async fn update_user_real_name(user_uuid:&String,key:&String) -> Option<UserKeyData> {
    if key.is_empty(){
        return None
    }
    return fejpsl_dao::user::update_user_real_name(user_uuid,key).await;
}
pub async fn update_user_area(user_uuid:&String,key:&String) -> Option<UserKeyData> {
    if key.is_empty(){
        return None
    }
    return fejpsl_dao::user::update_user_area(user_uuid,key).await;
}
//wall
pub async fn get_wall_list_by_page_no(page_no:&i32,user_uuid:&String) -> WallPageData {
    return fejpsl_dao::wall::get_wall_list_by_page_no(page_no,user_uuid).await;
}
pub async fn get_wall_reader_list_by_wall_id(wall_id:&i32) -> Option<Vec<WallReader>> {
    return fejpsl_dao::wall::get_wall_reader_list_by_wall_id(wall_id).await;
}
pub async fn get_wall_comment_list_by_page_no(page_no:&i32,wall_id:&i32) -> Option<Vec<WallComment>> {
    return fejpsl_dao::wall::get_wall_comment_list_by_page_no(page_no,wall_id).await;
}

//rank
pub async fn get_rank_fan_list_by_page_no(page_no:&i32) -> FanPageData {
    return fejpsl_dao::rank::get_rank_fan_list_by_page_no(page_no).await;
}
pub async fn get_rank_friend_level_score_list_by_page_no(page_no:&i32,user_uuid:&String) -> LevelScorePageData {
    return fejpsl_dao::rank::get_rank_friend_level_score_list_by_page_no(page_no,user_uuid).await;
}
pub async fn get_rank_world_level_score_list_by_page_no(page_no:&i32) -> LevelScorePageData {
    return fejpsl_dao::rank::get_rank_world_level_score_list_by_page_no(page_no).await;
}

//exam
pub async fn get_paper_list_by_page_no(page_no:&i32) -> PaperPageData {
    return fejpsl_dao::exam::exam_paper::get_paper_list_by_page_no(page_no).await;
}
pub async fn get_paper_list_by_category(page_no:&i32,category:&String) -> PaperPageData {
    return fejpsl_dao::exam::exam_paper::get_paper_list_by_category(page_no,category).await;
}
pub async fn get_paper_text_content_by_subject_id(subject_id:&i32) -> String {
    return fejpsl_dao::exam::exam_paper::get_paper_text_content_by_subject_id(subject_id).await;
}

pub async fn list_single_answer(subject_id:&i32) -> Option<Vec<SingleAnswer>> {
    return fejpsl_dao::exam::single_answer::list_single_answer(subject_id).await;
}
pub async fn get_single_answer_by_id(id:&i32) -> Option<SingleAnswer> {
    return fejpsl_dao::exam::single_answer::get_single_answer_by_id(id).await;
}
pub async fn list_multiple_answer(subject_id:&i32) -> Option<Vec<MultipleAnswer>> {
    return fejpsl_dao::exam::multiple_answer::list_multiple_answer(subject_id).await;
}
pub async fn get_multiple_answer_by_id(id:&i32) -> Option<MultipleAnswer> {
    return fejpsl_dao::exam::multiple_answer::get_multiple_answer_by_id(id).await;
}
pub async fn list_true_false_question(subject_id:&i32) -> Option<Vec<TrueFalseQuestion>> {
    return fejpsl_dao::exam::true_false_question::list_true_false_question(subject_id).await;
}
pub async fn get_true_false_question_by_id(id:&i32) -> Option<TrueFalseQuestion> {
    return fejpsl_dao::exam::true_false_question::get_true_false_question_by_id(id).await;
}
pub async fn list_blank_filling_question(subject_id:&i32) -> Option<Vec<BlankFillingQuestion>> {
    return fejpsl_dao::exam::blank_filling_question::list_blank_filling_question(subject_id).await;
}
pub async fn get_blank_filling_question_by_id(id:&i32) -> Option<BlankFillingQuestion> {
    return fejpsl_dao::exam::blank_filling_question::get_blank_filling_question_by_id(id).await;
}
//china
pub async fn get_province_list() -> Option<Vec<China>> {
    return fejpsl_dao::china::get_province_list().await;
}
pub async fn get_city_list(id:&String) -> Option<Vec<China>> {
    if id.is_empty() {
        return None
    }
    return fejpsl_dao::china::get_city_list(id).await;
}
//community
pub async fn get_my_room_list_by_page_no(page_no:&i32,user_uuid:&String) -> RoomPageData {
    return fejpsl_dao::community::room::get_my_room_list_by_page_no(page_no,user_uuid).await;
}
//hot room
pub async fn get_hot_room_list_by_page_no(page_no:&i32) -> RoomPageData {
    return fejpsl_dao::community::room::get_hot_room_list_by_page_no(page_no).await;
}
pub async fn create_room(user_uuid:&String) -> RoomKeyData {
    return fejpsl_dao::community::room::create_room(user_uuid).await;
}
pub async fn join_room(room_id:&i32,user_uuid:&String) ->MemberData {
    return fejpsl_dao::community::room::join_room(room_id,user_uuid).await;
}
pub async fn delete_room(room_id:&i32,user_uuid:&String) -> RoomData {
    return fejpsl_dao::community::room::delete_room(room_id,user_uuid).await;
}
pub async fn get_room_table_list_by_page_no(room_id:&i32,page_no:&i32) -> TablePageData {
    return fejpsl_dao::community::table::get_room_table_list_by_page_no(room_id,page_no).await;
}